package com.example.DynamicPermissionApplication;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.os.Bundle;
import android.util.Log;

import ru.alexbykov.nopermission.PermissionHelper;

public class MainActivity extends AppCompatActivity {
    private PermissionHelper permissionHelper;//权限申请
    String[] PermissionString={//需要提醒用户申请的权限
            Manifest.permission.CAMERA,
            Manifest.permission.ACCESS_FINE_LOCATION
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        permissionHelper = new PermissionHelper(this);//权限申请使用
        permissionHelper.check(PermissionString).onSuccess(new Runnable() {
            @Override
            public void run() {Log.e("e", "run: 允许" ); }
        }).onDenied(new Runnable() {
            @Override
            public void run() { Log.e("e", "run: 权限被拒绝" ); }
        }).onNeverAskAgain(new Runnable() {
            @Override
            public void run() { Log.e("e", "run: 权限被拒绝，下次不会在询问了" ); }
        }).run();
    }
    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        permissionHelper.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }
}
